package top.majuan.study.study.dao;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 数据库连接类
 */
public class DBHelper {
    public static final String DRIVER = "com.mysql.cj.jdbc.Driver";
    public static final String URL = "jdbc:mysql://teach_mysql.huhuiyu.top:31000/db_majuan?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai";
    public static final String USERNAME = "db_majuan";
    public static final String PASSWORD = "20050315majuan";

    static {
        try {
            Class.forName(DRIVER);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

    public static Connection getConnection() throws Exception {
        return DriverManager.getConnection(URL, USERNAME, PASSWORD);
    }
    public static void main(String[] args) throws Exception {
        Connection conn = DBHelper.getConnection();
        System.out.println(conn.getCatalog());
        conn.close();
    }
}


